package us.mooresr.webtroopmanager.client.place;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceTokenizer;

public class EditPersonPlace extends Place {
	private Long personId;
	
	public EditPersonPlace(Long personId) {
		this.personId = personId;
	}
	
	public Long getPersonId() {
		return personId;
	}
	
	public static class Tokenizer implements PlaceTokenizer<EditPersonPlace> {

		@Override
		public EditPersonPlace getPlace(String token) {
			Long personId;
			
			if ((token == null) || token.equals("null")) {
				personId = null;
			} else {
				personId = Long.parseLong(token);
			}
			
			return new EditPersonPlace(personId);
		}

		@Override
		public String getToken(EditPersonPlace place) {
			Long personId = place.getPersonId();
			
			if (personId == null) {
				return "null";
			} else {
				return personId.toString();
			}
		}
		
	}
}
